package com.huike.ormlite;

import android.os.Bundle;
import android.util.Log;
import android.view.View;

import java.util.List;

import androidx.appcompat.app.AppCompatActivity;

/**
 * ormlite 数据库使用
 *
 */
public class MainActivity extends AppCompatActivity {

    private UserDao userDao;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        userDao = new UserDao(this);

    }

    public void createClick(View v){
        User user = new User();
        user.setName("张三");
        user.setDesc("北京人");

        User user1 = new User();
        user1.setName("jack");
        user1.setDesc("湖北");

        User user2 = new User();
        user2.setName("tom");
        user2.setDesc("广西");

        userDao.addUser(user);
        userDao.addUser(user1);
        userDao.addUser(user2);

    }

    public void updateClick(View v){
        User user = new User();
        user.setId(1);
        user.setName("刘德华");
        user.setDesc("香港");
        userDao.updateUser(user);
    }

    public void queryClick(View v){
//        List<User> list = userDao.UserForName("jack");
        List<User> list = userDao.listAll();
        Log.i("TAG",list.toString());


//        Pwd pwd = pwdDao.queryId(1);
//        Log.i("TAG",pwd.toString());


    }



}
